<?php

function submit_prono($score_d,$score_e,$ID_m,$ID_j) {
	$sql = "INSERT INTO prono VALUES ('$ID_m', '$score_d', '$score_e', '$ID_j');";
	return query($sql);
}

function get_prono($idmatch, $idjoueur) {
    $sql = "SELECT * FROM prono WHERE ID_match = '$idmatch' AND ID_joueur = '$idjoueur';";
    return query($sql);
}

function prono_get_list($idmatch) {
    $sql = "SELECT * FROM prono WHERE ID_match = '$idmatch';";
    return query($sql);
}

function prono_exists($idmatch, $idjoueur) {
        $sql = "SELECT ID_joueur
                        FROM prono
                        WHERE ID_match = '$idmatch'
                        AND ID_joueur = '$idjoueur';";
        
        return mysql_num_rows(query($sql));
}

function update_prono($score_d,$score_e,$ID_m,$ID_j) {
        $sql = "UPDATE prono
                        SET pts_equipe_d = '$score_d',
							pts_equipe_e = '$score_e'
                        WHERE ID_match = '$ID_m'
                        AND ID_joueur = '$ID_j';";
        
        return query($sql);
}

function delete_prono($ID_m,$ID_j) {
        $sql = 'DELETE FROM prono WHERE ID_match = '.$ID_m.' AND ID_joueur = '.$ID_j.';'; 
        return query($sql);
}

function delete_prono_joueur($id){
	$sql = 'DELETE FROM prono WHERE ID_joueur = '.$id.';';
	return query ($sql);
}

function delete_all_prono(){
		$sql = 'DELETE FROM `prono`;'; 
		return query($sql);
}